package com.kangyi.user.mapper;

import com.kangyi.entity.ActivitySignup;
import com.kangyi.enumeration.OperationType;
import com.kangyi.user.annotation.AutoFill;
import com.kangyi.vo.ActivitySignupCountVO;
import com.kangyi.vo.ActivitySignupVO;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

/**
 * @author Blank
 * @version 1.0
 */
@Mapper
public interface ActivitySignupMapper {


    List<ActivitySignupVO> inquiryActivitySignup(Integer userId);

    List<ActivitySignupCountVO> countTotal(@Param("publicActivityIds") List<Integer> publicActivityIds);


    @Select("select count(*) from activity_signup where activity_id = #{activityId};")
    Integer collectTotal(Integer activityId);

    @Select("select * from activity_signup where guests_staying_id = #{guestsStayingId} and activity_id = #{activityId};")
    ActivitySignup getByGuestsStayingIdAndActivityId(@Param("guestsStayingId") Integer guestsStayingId,@Param("activityId") Integer activityId);

    @Insert("insert into activity_signup(user_id, guests_staying_id, activity_id, signup_time, status, create_user, update_user, create_time, update_time) " +
            "VALUES (#{userId},#{guestsStayingId},#{activityId},#{signupTime},#{status},#{createUser},#{updateUser},#{createTime},#{updateTime})")
    @AutoFill(value = OperationType.INSERT)
    void signUpActivity(ActivitySignup activitySignup);

    @Delete("delete from activity_signup where id = #{id};")
    void deleteActivitySignup(Integer id);

    @Select("select * from activity_signup where id = #{id};")
    ActivitySignup getById(Integer id);
}
